﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using JTC.Genetics.Molecules.Proteins.Filaments;
using JTC.Genetics.Molecules.Proteins;

namespace JTC.Genetics.UnitTests
{
    [TestClass]
    public class Filament_Tests
    {
        private Filament<Actin> _instance;

        [TestInitialize]
        public void SetUp()
        {
            _instance = new Filament<Actin>();
        }

        [TestMethod]
        public void can_add_Protien()
        {
            // Act

            _instance.Add(new Actin());

            // Assert

            Assert.AreEqual(1, _instance.Count);
        }

        [TestMethod]
        public void can_add_Multiple_Protiens()
        {
            // Act

            _instance.Add(new Actin());
            _instance.Add(new Actin());

            // Assert

            Assert.AreEqual(2, _instance.Count);
        }

        [TestMethod]
        public void can_Clear_Protiens()
        {
            // Arrange

            _instance.Add(new Actin());
            _instance.Add(new Actin());

            // Act

            _instance.Clear();
            
            // Assert

            Assert.AreEqual(0, _instance.Count);
        }

        [TestMethod]
        public void can_Remove_Protien()
        {
            // Arrange
            var p1 = new Actin();
            var p2 = new Actin();

            _instance.Add(p1);
            _instance.Add(p2);
            
            // Act

            _instance.Remove(p1);

            // Assert

            Assert.AreEqual(1, _instance.Count);
        }

        [TestMethod]
        public void can_CopyTo_Protiens()
        {
            // Arrange

            Actin[] array = new Actin[4];

            var p1 = new Actin();
            var p2 = new Actin();

            _instance.Add(p1);
            _instance.Add(p2);
            
            // Act

            _instance.CopyTo(array, 1);

            // Assert

            Assert.AreEqual(4, array.Length);
            Assert.IsNull(array[0]);
            Assert.IsNotNull(array[1]);
            Assert.IsNotNull(array[2]);
            Assert.IsNull(array[3]);
        }
    }
}
